// @algorithm @lc id=100322 lang=cpp
// @title he-wei-sde-liang-ge-shu-zi-lcof

#include "algm/algm.h"
#include <iostream>
#include <string>
#include <vector>
using namespace std;
class Solution {
public:
    vector<int> twoSum(vector<int> &nums, int target) {
        int n = nums.size();
        int left = 0, right = n - 1;
        while (left < right) {
            int sum = nums[left] + nums[right];
            if (sum == target) {
                return vector<int>{nums[left], nums[right]};
            }
            else if (sum < target) {
                ++left;
            }
            else {
                --right;
            }
        }
        return {};
    }
};